package wbhproject.tests;

import java.io.File;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;

import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

public class DOMParserTest {

	public static void main(String[] args) {
		System.out.println("Programm läuft an...");
		DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
		try {
			DocumentBuilder db = dbf.newDocumentBuilder();
			Document doc = db.parse(new File(
					"/Users/thomas/Downloads/domtest.xml"));
			doc.getDocumentElement().normalize();
			Element city = (Element) doc.getDocumentElement().getElementsByTagName("city").item(0);
			System.out.println("City:" + city.getAttribute("id") + ":" + city.getAttribute("name"));
		} catch (Exception e) {
			System.out.println(e.getMessage());
		}
	}

}
